#include <iostream>
#include <string>
#include <cstring>
using namespace std;

string s;
int dp[510][510]; //表示最长回文子序列长度

int minInsertions(string s)
{
   memset(dp,0,sizeof(dp));
   for(int i=s.length()-1;i>=0;i--){
       dp[i][i] = 1;
       for(int j = i+1;j<s.length();j++){
           if(s[i] == s[j]) dp[i][j] = dp[i+1][j-1] +2;
           else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
       }
   }
    return s.length()-dp[0][s.length()-1];
}

int main()
{
    cin >> s;
    int ans = minInsertions(s);
    cout << ans << endl;
    system("pause");
    return 0;
}